var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function () {
        var t = function (e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function (e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })();
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("WX"),
    a = t("ConfS"),
    i = t("Const"),
    s = t("locales"),
    c = t("LingquJiangli"),
    l = t("LoadingInfos"),
    u = t("OpenDataContexts"),
    p = t("PlatformCtrl"),
    f = t("Platforms"),
    d = (function (t) {
        function e() {
            var e = t.call(this) || this;
            return (e.请求返回值套一层data = !0), e;
        }
        return (
            n(e, t),
            (e.prototype.获取物理参数 = function () {
                var t = wx.getSystemInfoSync();
                (this.screenWidth = t.screenWidth),
                    (this.screenHeight = t.screenHeight),
                    (this.language = "zh"),
                    (this.粪叉 = !!t.model && t.model.toLowerCase().replace(/\s+/g, "").indexOf("iphonex") > -1);
            }),
            (e.prototype.wx_init = function (t) {
                var e = this;
                i.default.显示分享
                    ? (wx.showShareMenu({withShareTicket: !0, menus: ["shareAppMessage", "shareTimeline"]}),
                      (wx.aldOnShareAppMessage || wx.onShareAppMessage)(function () {
                          return e.getShare();
                      }),
                      wx.onShareTimeline &&
                          wx.onShareTimeline(function () {
                              return e.getShare();
                          }))
                    : wx.hideShareMenu({});
                var o = wx.getLaunchOptionsSync();
                (this.launchScene = o.scene || 0),
                    (this.launchQuery = o.query),
                    this.addLaunchOption(o),
                    wx.onShow(this._onShow),
                    wx.onHide(this._onHide),
                    l.default.start("获取配置"),
                    wx.getSetting({
                        success: function (o) {
                            l.default.end("获取配置"),
                                o.authSetting["scope.userInfo"] &&
                                    (l.default.start("获取用户信息"),
                                    wx.getUserInfo({
                                        success: function (t) {
                                            l.default.end("获取用户信息"),
                                                e.initUserInfo(
                                                    t.userInfo.nickName,
                                                    t.userInfo.gender,
                                                    t.userInfo.avatarUrl
                                                );
                                        },
                                        fail: function (t) {
                                            console.error("wx.getUserInfo() fail " + JSON.stringify(t));
                                        }
                                    })),
                                e._init(t);
                        },
                        fail: function (t) {
                            console.error("wx.getSetting() fail" + JSON.stringify(t));
                        }
                    }),
                    wx.setKeepScreenOn && wx.setKeepScreenOn({keepScreenOn: !0});
            }),
            (e.prototype.checkLogin = function (e) {
                wx.checkSession
                    ? wx.checkSession({
                          success: function () {
                              console.log("session_key 未过期，并且在本生命周期一直有效"), e && e(!0);
                          },
                          fail: function () {
                              console.log("session_key 已经失效，需要重新执行登录流程"), e && e(!1);
                          }
                      })
                    : t.prototype.checkLogin.call(this, e);
            }),
            (e.prototype.各种东西都加载完了 = function () {
                wx.aldSendOpenid && wx.aldSendOpenid(f.default.userStorage.openId),
                    this.使用开放域 && u.default.setOpenId(),
                    t.prototype.各种东西都加载完了.call(this);
            }),
            (e.prototype._openCPB = function (t, e, o) {
                wx.navigateToMiniProgram &&
                    wx.navigateToMiniProgram({appId: t.appId, path: t.path, success: e, fail: o});
            }),
            (e.prototype.createFeedbackButton = function (t) {
                this.显示联系我们 &&
                    wx.createFeedbackButton &&
                    (this.feedbackButton = wx.createFeedbackButton({
                        type: "text",
                        text: "",
                        style: {left: t[0], top: t[1], width: t[2], height: t[3]}
                    }));
            }),
            (e.prototype.destroyFeedbackButton = function () {
                this.feedbackButton && (this.feedbackButton.destroy(), (this.feedbackButton = null));
            }),
            (e.prototype.createUserInfoButton = function (t, e) {
                var o = this;
                if (!this.已授权 && wx.createUserInfoButton) {
                    var n = wx.createUserInfoButton({
                        type: "text",
                        text: "",
                        style: {left: t[0], top: t[1], width: t[2], height: t[3]}
                    });
                    return (
                        n.onTap(function (t) {
                            t.userInfo &&
                                (o.destroyUserInfoButtons(),
                                o.initUserInfo(t.userInfo.nickName, t.userInfo.gender, t.userInfo.avatarUrl),
                                e && e());
                        }),
                        this.userInfoButtons || (this.userInfoButtons = new Array()),
                        this.userInfoButtons.push(n),
                        n
                    );
                }
            }),
            (e.prototype.initUserInfo = function (t, e, o) {
                (this.已授权 = !0),
                    (f.default.userStorage.nickname = t),
                    (f.default.userStorage.gender = e),
                    (f.default.userStorage.headImgURL = o),
                    f.default.userStorage.setDirty();
            }),
            (e.prototype.destroyUserInfoButton = function (t) {
                if (this.userInfoButtons && t) {
                    var e = this.userInfoButtons.indexOf(t);
                    e > -1 && (t.destroy(), this.userInfoButtons.splice(e, 1));
                }
            }),
            (e.prototype.destroyUserInfoButtons = function () {
                if (this.userInfoButtons) {
                    for (var t = 0, e = this.userInfoButtons; t < e.length; t++) {
                        e[t].destroy();
                    }
                    (this.userInfoButtons.length = 0), (this.userInfoButtons = null);
                }
            }),
            (e.prototype.openDayGem = function () {
                var t = this;
                wx.openCustomerServiceConversation &&
                    wx.openCustomerServiceConversation({
                        showMessageCard: !0,
                        sendMessageImg: i.default.客服签到领钻石按钮,
                        sendMessagePath: "签到",
                        sendMessageTitle: "签到",
                        success: function (e) {
                            "签到" == e.path &&
                                (f.default.userStorage.已客服签到
                                    ? t.toast("您今天已签过到，明天再来吧！")
                                    : ((f.default.userStorage.已客服签到 = !0),
                                      f.default.userStorage.setDirty(),
                                      f.default.popups
                                          .show(c.LingquJiangli)
                                          .set(
                                              a.DatasManager.客服签到领奖励货币,
                                              a.DatasManager.客服签到领奖励货币数量,
                                              0,
                                              "明天也要记得来签到哦！"
                                          ),
                                      i.default.更新客服签到小红点()));
                        }
                    });
            }),
            (e.prototype._share = function (e, o) {
                t.prototype._share.call(this, e, o),
                    this.显示分享
                        ? wx.aldShareAppMessage
                            ? wx.aldShareAppMessage(o)
                            : wx.shareAppMessage &&
                              (e && e.share && e.share._wx_branchIds && (o.wxgamebranchid = e.share._wx_branchIds[0]),
                              wx.shareAppMessage(o))
                        : this.toast("游戏内测中，暂不支持分享。");
            }),
            (e.prototype.闯关开始 = function (e, o, n) {
                t.prototype.闯关开始.call(this, e, o, n);
            }),
            (e.prototype.闯关ing = function () {
                t.prototype.闯关ing.call(this);
            }),
            (e.prototype.闯关结束 = function (e) {
                t.prototype.闯关结束.call(this, e);
            }),
            (e.prototype._get = function (t, e, o, n, r, a) {
                var i = this;
                var s = this.getURL(t, o, e),
                    c = this.getCache(s, !1);
                c && (console.log("使用缓存数据"), this.requestComplete(o, s, c, !1, r, a), (r = null), (a = null)),
                    wx.request({
                        url: s,
                        method: "GET",
                        success: function (t) {
                            i.requestComplete(o, s, t, !1, r, a);
                        },
                        fail: function () {
                            console.error("get " + s + " 失败！"), i.requestError(o, s, a);
                        }
                    });
            }),
            (e.prototype._post = function (t, e, o, n, r, a) {
                var i = this,
                    s = this.getURL(t, o, e),
                    c = {"Content-Type": "application/x-www-form-urlencoded"};
                this.使用SessionId && (c.Cookie = "SESSION=" + wx.getStorageSync("sessionId")),
                    wx.request({
                        url: s,
                        method: "POST",
                        header: c,
                        data: o,
                        success: function (t) {
                            i.requestComplete(o, s, t, !1, n, r);
                        },
                        fail: function () {
                            console.error("post " + s + " 失败！"), i.requestError(o, s, r);
                        }
                    });
            }),
            (e.prototype.dd = function (e, o) {
                if ((t.prototype.dd.call(this, e, o), wx.aldSendEvent)) {
                    var n = r.default.branchId2name(e);
                    n && (console.log("阿拉丁打点 " + n + " " + JSON.stringify(o)), wx.aldSendEvent(n, o));
                }
            }),
            (e.prototype.toast = function (e) {
                return (e = t.prototype.toast.call(this, e)), wx.showToast({title: e, icon: "none"}), e;
            }),
            (e.prototype.checkUpdate = function () {
                var t = wx.getUpdateManager();
                t.onCheckForUpdate(function (t) {}),
                    t.onUpdateReady(function () {
                        wx.showModal({
                            title: "提示",
                            content: s.locales.getText([
                                a.DatasManager.更新提示CN,
                                a.DatasManager.更新提示CN,
                                a.DatasManager.更新提示EN
                            ]),
                            success: function () {
                                t.applyUpdate();
                            },
                            showCancel: !1,
                            confirmText: "更 新"
                        });
                    }),
                    t.onUpdateFailed(function () {
                        console.error("updateManager.onUpdateFailed");
                    });
            }),
            (e.prototype.显示一键添加到我的小程序 = function () {
                wx.showFavoriteGuide &&
                    wx.showFavoriteGuide({
                        type: "tip",
                        content: "一键添加到我的小程序",
                        success: function (t) {
                            console.log("一键添加到我的小程序成功，" + JSON.stringify(t));
                        },
                        fail: function (t) {
                            console.log("一键添加到我的小程序失败，" + JSON.stringify(t));
                        }
                    });
            }),
            (e.prototype.removeUserCloudStorage = function () {
                wx.removeUserCloudStorage &&
                    wx.removeUserCloudStorage({
                        keyList: ["data", "inter"],
                        success: function (t) {
                            console.log("removeUserCloudStorage " + JSON.stringify(t));
                        },
                        fail: function () {
                            console.error("removeUserCloudStorage 失败");
                        }
                    });
            }),
            (e.prototype.加载完毕 = function () {
                t.prototype.加载完毕.call(this),
                    r.default.测速(r.default.测速s.loaded),
                    wx.markScene && wx.markScene({sceneId: 0});
            }),
            (e.prototype.exit = function () {
                wx.exitMiniProgram && wx.exitMiniProgram({});
            }),
            e
        );
    })(p.default);
o.default = d;
